cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(recipe-02 LANGUAGES CXX)

add_executable(hello-world hello-world.cpp)

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
#    target_compile_definitions(hello-world PUBLIC IS_LINUX)                 # 编译定义宏IS_LINUX
    add_definitions(-DIS_LINUX)                                             # 没有权限限制，影响整个项目
elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
    target_compile_definitions(hello-world PUBLIC IS_WINDOWS)
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
    target_compile_definitions(hello-world PUBLIC IS_MACOS)
endif ()